package com.senseuni.da.ui.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.senseuni.common.dialog.CBDialogBuilder;
import com.senseuni.common.dialog.OnDialogResultListener;
import com.senseuni.da.R;

public class PowerDialog extends CBDialogBuilder {

    public PowerDialog(Context context) {
        super(context, CBDialogBuilder.DIALOG_STYLE_NORMAL, (float) 0.3);
        initView(context);
    }

    private void initView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_power, null);

        view.findViewById(R.id.tv_power).setOnClickListener(v -> {
            getDialog().dismiss();
            mListener.onResult(null, 0);
        });

        view.findViewById(R.id.tv_reboot).setOnClickListener(v -> {
            getDialog().dismiss();
            mListener.onResult(null, 1);
        });

        view.findViewById(R.id.tv_sleep).setOnClickListener(v -> {
            getDialog().dismiss();
            mListener.onResult(null, 2);
        });

        setView(view);
        setTouchOutSideCancelable(true);
        showButton(false);
        showClose(false);
    }

    private OnDialogResultListener<Integer> mListener;

    public void setOnResultListener(OnDialogResultListener<Integer> listener) {
        mListener = listener;
    }


}
